<?php
/**
 * @author Laurent SITTLER <lolo.sittler@gmail.com>
 * @author Alexandre GOMEZ <gomez.alexandre02@gmail.com>
 * @version 0.1
 */
require_once 'Library/Culture.php';
require_once 'Model/User_Model.php';

/**
 *  View Logs
 */
echo '<h3>Historique</h3>';

Culture::FormatDate();

$infos = new Informations_Model();

$logs = $infos->GetAllLogs();
if (!empty($logs)) {
//        print_r($result);
    echo '<table id="mt" class="tableContent" width="100%">';
    echo '<tr class="header">';
    foreach (array_keys($logs[0]) as $key) {
        echo '<th>' . $key . '</th>';
    }
    echo '</tr>';
    $LineLog = 0;
    foreach ($logs as $tb) {
        if ($LineLog % 2)
            echo '<tr class="style">';
        else
            echo '<tr>';
        foreach ($tb as $key => $value) {
            if ($key == 'LOG_USER_ID') {
                $logUser = new User_Model();
                $user = $logUser->GetUserById($value);
                echo '<td>' . $user->GetLogin() . '</td>';
            } else {
                echo '<td>' . $value . '</td>';
            }
        }
        echo '</tr>';
        $LineLog++;
    }
    echo '</table>';
    echo '<input type="hidden" value="' . $LineLog . '" id="nblog">';
    echo '<div id="pagination"></div>';
}
?>
<script type="text/javascript">
    $(document).ready(function(){
        var nblog = $("#nblog").val();
        
        $('#pagination').smartpaginator({
            totalrecords: nblog,
            recordsperpage: 20, 
            datacontainer: 'mt', 
            dataelement: 'tr',
            theme: 'blue' });
    });
</script>

